//
//  ZTNoPermissionsViewController.m
//  ZTPrivateLib
//
//  Created by 武得亮 on 2021/6/1.
//

#import "ZTNoPermissionsViewController.h"
#import "ZTMacros.h"
@interface ZTNoPermissionsViewController ()

/** 图片 */
@property (nonatomic, strong) UIImageView *noperImg;

@end

@implementation ZTNoPermissionsViewController

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:animated];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.title = self.navigationTitle;
    [self.view addSubview:self.noperImg];
    if (IOS11) {
        if (self.navigationController.viewControllers.count > 1) {
            id target = self.navigationController.interactivePopGestureRecognizer.delegate;
            SEL handler = NSSelectorFromString(@"handleNavigationTransition:");

            // 创建全屏滑动手势，调用系统自带滑动手势的target的action方法
            UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:target action:handler];
            
            // 设置手势代理，拦截手势触发
            pan.delegate = self;
            
            // 给导航控制器的view添加全屏滑动手势
            [self.view addGestureRecognizer:pan];
            
            // 禁止使用系统自带的滑动手势
            self.navigationController.interactivePopGestureRecognizer.enabled = NO;
            
            
            /** bundle 引用*/
            NSBundle *associateBunle = [NSBundle bundleWithPath:[[NSBundle bundleForClass:[self class]] pathForResource:@"ZTPrivateLib" ofType:@"bundle"]];
       self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"chat_back"
                                                                                                  inBundle: associateBunle
                                                                                                compatibleWithTraitCollection:nil] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:(UIBarButtonItemStylePlain) target:self action:@selector(backClick)];
        }
    }
}

-(void)backClick
{
    [self.navigationController popToRootViewControllerAnimated:YES];
}


-(UIImageView *)noperImg
{
    if (_noperImg == nil) {
        _noperImg = [[UIImageView alloc]init];
        NSBundle *associateBunle = [NSBundle bundleWithPath:[[NSBundle bundleForClass:[self class]] pathForResource:@"ZTPrivateLib" ofType:@"bundle"]];
        UIImage *noperImage = [UIImage imageNamed:@"ztnopermissions"
                                             inBundle: associateBunle
                    compatibleWithTraitCollection:nil];
        [_noperImg setFrame:CGRectMake((KScreenWidth - noperImage.size.width)/2, (KScreenHeight - noperImage.size.height)/2 - SafeAreaTopHeight, noperImage.size.width, noperImage.size.height)];
        [_noperImg setImage:noperImage];
    }
    return _noperImg;
}


@end
